﻿using QInjection.Injector.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QInjection.Injector
{
    internal class ElementsMap 
    {
        private Dictionary<Element, List<ElementMapping>> _map;

        internal ElementsMap(IConfigurator instructor)
        {
            _map = new Dictionary<Element, List<ElementMapping>>();
            foreach (var e in instructor.Elements)
            {
                _map[e] = new List<ElementMapping>();
                foreach (var c in instructor.Tuples(e))
                {
                    _map[e].Add(new ElementMapping()
                    {
                        Node = c.Item1,
                        Branch = c.Item2,
                    });
                }
            }
        }

        internal List<ElementMapping> this[Element item]
        {
            get
            {
                return _map[item];
            }
        }

        internal bool ContainsKey(Element key)
        {
            return _map.ContainsKey(key);
        }
    }
}
